package com.streamsets.datacollector.model.jdbc;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.io.Serializable;

/**
 * 设置JDBC目标数据库需要的参数
 * @author wengzhonghui
 * @date 2019/6/18 19:32
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class DestinationJdbcConfigJson implements Serializable {

    // 入库目标表的表名
    String targetTable;
    // 入库目标表的库名
    String targetSchemaName;
    // 入库操作例如insert,update,delete,
    String defaultOperation;
    // 数据库JDBC连接，如jdbc:mysql://172.30.0.62:3306/streamset_test
    String connectionString;
    String jdbcUserName;
    String jdbcPassword;
    String driverClassName;
    String connectionTestQuery;

    public DestinationJdbcConfigJson() {
    }

    public DestinationJdbcConfigJson(
            @JsonProperty("targetTable")String targetTable,
            @JsonProperty("targetSchemaName")String targetSchemaName,
            @JsonProperty("defaultOperation")String defaultOperation,
            @JsonProperty("connectionString")String connectionString,
            @JsonProperty("jdbcUserName")String jdbcUserName,
            @JsonProperty("jdbcPassword")String jdbcPassword,
            @JsonProperty("driverClassName")String driverClassName,
            @JsonProperty("connectionTestQuery")String connectionTestQuery) {

        defaultOperation = defaultOperation==null? "INSERT" : defaultOperation;
        this.targetSchemaName = targetSchemaName;
        this.targetTable = targetTable;
        this.defaultOperation = defaultOperation;
        this.connectionString = connectionString;
        this.jdbcUserName = jdbcUserName;
        this.jdbcPassword = jdbcPassword;
        this.driverClassName = driverClassName;
        this.connectionTestQuery = connectionTestQuery;
    }

    public String getTargetTable() {
        return targetTable;
    }

    public void setTargetTable(String targetTable) {
        this.targetTable = targetTable;
    }

    public String getDefaultOperation() {
        return defaultOperation;
    }

    public void setDefaultOperation(String defaultOperation) {
        this.defaultOperation = defaultOperation;
    }

    public String getConnectionString() {
        return connectionString;
    }

    public void setConnectionString(String connectionString) {
        this.connectionString = connectionString;
    }

    public String getJdbcUserName() {
        return jdbcUserName;
    }

    public void setJdbcUserName(String jdbcUserName) {
        this.jdbcUserName = jdbcUserName;
    }

    public String getJdbcPassword() {
        return jdbcPassword;
    }

    public void setJdbcPassword(String jdbcPassword) {
        this.jdbcPassword = jdbcPassword;
    }

    public String getDriverClassName() {
        return driverClassName;
    }

    public void setDriverClassName(String driverClassName) {
        this.driverClassName = driverClassName;
    }

    public String getConnectionTestQuery() {
        return connectionTestQuery;
    }

    public void setConnectionTestQuery(String connectionTestQuery) {
        this.connectionTestQuery = connectionTestQuery;
    }

    public String getTargetSchemaName() {
        return targetSchemaName;
    }

    public void setTargetSchemaName(String targetSchemaName) {
        this.targetSchemaName = targetSchemaName;
    }
}
